package org.example.struct.array3;

import java.util.ArrayList;
import java.util.List;

/**
 * @author liyishan
 * @date 2024/6/17 10:41
 * @apiNote
 */

public class Test00004FindMedianSortedArrays {

    public double findMedianSortedArrays(int[] nums1, int[] nums2) {
        List<Integer> allList = new ArrayList<>();
        for (int j : nums1) {
            allList.add(j);
        }
        for (int j : nums2) {
            allList.add(j);
        }
        allList.sort(Integer::compareTo);
        int size = allList.size()/2;
        if (allList.size() % 2 == 0){
            return (allList.get(size-1) + allList.get(size)) / 2.0;
        }else {
            return allList.get(size);
        }
    }
}
